[#include "../../../common/html.ftl" /]
[@html]
    [@head title="操作日志列表" css=["fw", "bootstrap-table"] /]
    [@body]
        [#--主体内容--]
        [@main ]
            <div class="am-g am-radius fw-tables">
                [#--表格主体内容--操作栏--]
                [@mainHeader]
                    [#--[@shiro.hasPermission name="monitor:operlog:remove"]--]
                    <button class="am-btn am-btn-danger am-radius multiple am-disabled" onclick="$.operate.removeAll()">删除</button>
                    [#--[/@shiro.hasPermission]--]
                    [#--[@shiro.hasPermission name="monitor:operlog:remove"]--]
                    <button class="am-btn am-btn-danger am-radius" onclick="$.operate.clean()">清空</button>
                    [#--[/@shiro.hasPermission]--]
                [/@mainHeader]

                [#--表格主体内容--搜索栏--]
                [@searchForm searchId="form-operlog-search" ]
                    <div class="am-form-group">
                        <input type="text" name="operName" class="am-form-field am-input-sm am-radius" placeholder="登录账号">
                    </div>
                    <div class="am-form-group">
                        <input type="text" name="userName" class="am-form-field am-input-sm am-radius" placeholder="操作人员">
                    </div>
                    <div class="am-form-group">
                        <select name="businessType" class="am-radius" data-am-selected placeholder="操作类型">
                            <option value=""></option>
                            [#list dict.getType("sys_oper_type") as dict]
                                <option value="${dict.dictValue}">${dict.dictLabel}</option>
                            [/#list]
                        </select>
                    </div>
                    <div class="am-form-group">
                        <select name="status" class="am-radius" data-am-selected placeholder="操作状态">
                            <option value=""></option>
                            [#list dict.getType("sys_oper_status") as dict]
                                <option value="${dict.dictValue}">${dict.dictLabel}</option>
                            [/#list]
                        </select>
                    </div>
                    <div class="am-form-group">
                        <div class="am-form-group am-form-icon">
                            <i class="am-icon-calendar"></i>
                            <input type="text" name="params[beginTime]" class="am-form-field am-input-sm am-radius" placeholder="操作时间-开始"
                                   data-am-datepicker readonly/>
                        </div>
                        <div class="am-form-group am-form-icon">
                            <i class="am-icon-calendar"></i>
                            <input type="text" name="params[endTime]" class="am-form-field am-input-sm am-radius" placeholder="操作时间-结束"
                                   data-am-datepicker readonly/>
                        </div>
                    </div>
                [/@searchForm]

                <div class="fw-table">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        [/@main]

        [#--PC/APP 右侧悬浮按钮--]
        [@rightToolbar /]

        [@script js=["fw", "bootstrap-table"]]
            <script type="text/javascript">
                [#--var detailFlag = "${hasPermission('monitor:operlog:detail')}";--]
                var detailFlag = "";
                var datas = ${convert.toJson(dict.getType("sys_oper_type"))};
                var isAdministrator = ${convert.toJson(common.isAdministrator())};

                var prefix = ctx + "osfw/system/monitor/operlog";

                $(function () {
                    var options = {
                        url: prefix + "/list",
                        cleanUrl: prefix + "/clean",
                        detailUrl: prefix + "/detail/{id}",
                        removeUrl: prefix + "/remove",
                        exportUrl: prefix + "/export",
                        modalName: "操作日志",
                       /* escape: false,
                        showPageGo: false,*/
                        rememberSelected: true,
                        uniqueId: "operId",
                        // search: false,
                        columns: [
                            {
                                // field: 'state',
                                checkbox: true
                            },
                            {
                                title: "序号",
                                formatter: function (value, row, index) {
                                    return $.table.serialNumber(index);
                                }
                            },
                            {
                                field: 'title',
                                title: '业务名称'
                            },
                            {
                                field: 'businessType',
                                title: '操作类型',
                                align: 'left',
                                formatter: function (value, row, index) {
                                    return $.table.selectDictLabel(datas, value);
                                }
                            },
                            {
                                field: 'operName',
                                title: '操作人员',
                                sortable: true
                            },
                            {
                                field: 'deptName',
                                title: '所属部门'
                            },
                            {
                                field: 'operIp',
                                title: '操作地址'
                            },
                            {
                                field: 'operLocation',
                                title: '操作地点',
                                visible: false,
                            },
                            {
                                field: 'status',
                                title: '操作状态',
                                align: 'left',
                                formatter: function (value, row, index) {
                                    if (value == 0) {
                                        return '<span class="badge badge-primary">成功</span>';
                                    } else if (value == 1) {
                                        return '<span class="badge badge-danger">失败</span>';
                                    }
                                }
                            },
                            {
                                field: 'operTime',
                                title: '操作时间',
                                sortable: true
                            },
                            {
                                title: '操作',
                                cellStyle: operCellStyle,
                                formatter: function (value, row, index) {
                                    var actions = [];
                                    actions.push('<a class="am-badge am-badge-transparent am-radius ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.operId + '\')">详细</a>');
                                    return actions.join('');
                                }
                            }]
                    };
                    $.table.init(options);
                });

                function searchPre() {
                    var data = {};
                    data.businessTypes = $.common.join($('#businessTypes').selectpicker('val'));
                    $.table.search('operlog-form', 'bootstrap-table', data);
                }

                function resetPre() {
                    $("#operlog-form")[0].reset();
                    $("#businessTypes").selectpicker('refresh');
                    $.table.search('operlog-form', 'bootstrap-table');
                }

            </script>
        [/@script]
    [/@body]
[/@html]
